# Contributor: wener <wenermail@gmail.com>
# Maintainer: wener <wenermail@gmail.com>
pkgname=sqlcipher
pkgver=4.4.0
pkgrel=0
pkgdesc="SQLCipher is an SQLite extension that provides 256 bit AES encryption of database files."
url="https://www.zetetic.net/sqlcipher/"
arch="all"
license="BSD-3-clause"
makedepends="openssl-dev tcl-dev readline-dev zlib-dev"
subpackages="$pkgname-dev $pkgname-doc $pkgname-libs"
source="$pkgname-$pkgver.tar.gz::https://github.com/sqlcipher/sqlcipher/archive/v$pkgver.tar.gz"
# block by https://github.com/sqlcipher/sqlcipher/issues/368#issuecomment-669984195
options="!check"

build() {
	export CFLAGS="$CFLAGS -DSQLITE_HAS_CODEC"
	export LDFLAGS="$LDFLAGS -lcrypto"

	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--enable-tempstore=yes \
		--enable-fts5

	make
}

check() {
	make testfixture
	./testfixture test/sqlcipher.test
}

package() {
	make DESTDIR="$pkgdir" install

	install -Dm0644 sqlcipher.1 \
		"$pkgdir"/usr/share/man/man1/sqlcipher.1
}

libs() {
	pkgdesc="SQLCipher library"
	mkdir -p "$subpkgdir"/usr
	mv "$pkgdir"/usr/lib "$subpkgdir"/usr/
}

sha512sums="e6e7b09cc079d75ac0b9e15a256bfe479ce97cfdece3244ca53e2e04b7f1dc1afdc1ee76d07f2629e614c7532cc80eeef6b85ba5952d31a2eaed8d6e84414628  sqlcipher-4.4.0.tar.gz"
